#include <iostream>
#include <stdio.h>
#include <stdlib.h>
using namespace std;

int main()
{
    std::ios::sync_with_stdio(false);
    int i,n,j,a[1000000],k;
    cin>>n;
    for(i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    cin>>j;
    while(j>0)
    {
        cin>>k;
        int low=1,high=n,mid;
        while(low<=high)
        {
            mid=(low+high)/2;
            if(a[mid]==k) break;
            else if(a[mid]>k)
            {
                high=mid-1;
            }
            else low=mid+1;
        }
        if(a[mid]==k)
            cout<<mid<<endl;
        else if(low>high)
            cout<<low<<endl;
        j--;
    }
    return 0;
}
